class Name {

}

object Name {
  def unapply(input: String): Option[(String, String)] = {
    val pos = input.indexOf(" ")
    if (pos == -1) None
    else Some((input.substring(0, pos), input.substring(pos + 1)))
  }
}

object IsCompound {
  def unapply(input: String): Option[(Boolean, String)] = Some (input.contains(" "), input)
}

object Sheet11 extends App {
  val author = "Cedric van der Linden"
  author match {
    case Name(first, IsCompound(_, last)) => print(first + " " + last);
    case Name(first, last) => printf("%s, %s", first, last)
  }
}